******************************************************************************
	*** Table 3 ***
******************************************************************************
	
	//Use main data
	use "${maindta}", clear
	
	//Get different summary statistics 
	
	*Mean
	rifhdreg firm_score_est [pw=wt], rif(mean)
	scalar _mn_val = r(table)[1,1]
	local _mn : display %4.1f _mn_val

	*10th, 25th, 50th, 75th, 90th
	foreach q in 10 25 50 75 90 {
		rifhdreg firm_score_est [pw=wt], rif(q(`q'))
		scalar _p`q'_val = r(table)[1,1]
		local _p`q' : display %4.1f  _p`q'_val
	}
	
	*SD
	rifhdreg firm_score_est [pw=wt], rif(std)
	scalar _sd_val = r(table)[1,1]
	local _sd : display %4.1f _sd_val
	
	gen table3=""
	replace table3 = " & Mean & 10th & 25th & 50th & 75th & 90th & S.D." in 1
	replace table3 = "Influence score & `_mn' & `_p10' & `_p25' & `_p50' & `_p75' & `_p90' & `_sd'" in 2

	export delimited table3 using "${outtables}\\Table3.txt", nolabel noquote replace